	var serviceExpireListArr = [{
    	"sClass": "text-left",
        "data": "memberName"
    },{
    	"sClass": "text-left",
        "data": "enName"
    },{
    	"sClass": "text-left",
        "data": "serviceName"
    },{
    	"sClass": "text-left",
        "data": "serviceType"
    },{
    	"sClass": "text-left",
        "data": "buyStartDate"
    },{
    	"sClass": "text-left",
        "data": "buyEndDate"
    },{
    	"sClass": "text-left",
        "data": "amount"
    },{
    	"sClass": "text-left",
        "data": "expireNumber"
    },{
    	"sClass": "text-left",
        "data": "id",
        "render": function (data, type, full, meta) {
        	return '<button class="cabtn cabtn_danger" onclick="rejectRenew(\'' + data + '\');">拒绝续约</button>';
        }
    }];
	
	var planBuyExpireListArr = [{
    	"sClass": "text-left",
        "data": "memberName"
    },{
    	"sClass": "text-left",
        "data": "enName"
    },{
    	"sClass": "text-left",
        "data": "serviceName"
    },{
    	"sClass": "text-left",
        "data": "serviceType"
    },{
    	"sClass": "text-left",
        "data": "planDate"
    },{
    	"sClass": "text-left",
        "data": "remindDate"
    },{
    	"sClass": "text-left",
        "data": "expireNumber"
    }];
	
	var planBuyReturnListArr = [{
    	"sClass": "text-left",
        "data": "memberName"
    },{
    	"sClass": "text-left",
        "data": "enName"
    },{
    	"sClass": "text-left",
        "data": "serviceName"
    },{
    	"sClass": "text-left",
        "data": "serviceType"
    },{
    	"sClass": "text-left",
        "data": "planDate"
    },{
    	"sClass": "text-left",
        "data": "remindDate"
    },{
    	"sClass": "text-left",
        "data": "returnVisitNum"
    }];
	
	var mrExpireListArr = [{
    	"sClass": "text-left",
        "data": "memberName"
    },{
    	"sClass": "text-left",
        "data": "enName"
    },{
    	"sClass": "text-left",
        "data": "sex"
    },{
    	"sClass": "text-left",
        "data": "telephone"
    },{
    	"sClass": "text-left",
        "data": "mobile"
    },{
    	"sClass": "text-left",
        "data": "familyTel"
    },{
    	"sClass": "text-left",
        "data": "workTel"
    },{
    	"sClass": "text-left",
        "data": "wechatNum"
    },{
    	"sClass": "text-left",
        "data": "returnVisitDate"
    },{
    	"sClass": "text-left",
        "data": "expireNumber"
    },{
    	"sClass": "text-left",
        "data": "memberId",
        "render": function (data, type, full, meta) {
        	return '<button class="cabtn cabtn_success" onclick="toReturnTimeForm(\'' + data + '\');">下次回访时间</button>';
        }
    }];
	
	var memberReturnListArr = [{
    	"sClass": "text-left",
        "data": "memberName"
    },{
    	"sClass": "text-left",
        "data": "enName"
    },{
    	"sClass": "text-left",
        "data": "sex"
    },{
    	"sClass": "text-left",
        "data": "telephone"
    },{
    	"sClass": "text-left",
        "data": "mobile"
    },{
    	"sClass": "text-left",
        "data": "familyTel"
    },{
    	"sClass": "text-left",
        "data": "workTel"
    },{
    	"sClass": "text-left",
        "data": "wechatNum"
    },{
    	"sClass": "text-left",
        "data": "returnVisitNum"
    }];
	
	var makeOverExpireListArr = [{
    	"sClass": "text-left",
        "data": "memberName"
    },{
    	"sClass": "text-left",
        "data": "enName"
    },{
    	"sClass": "text-left",
        "data": "sex"
    },{
    	"sClass": "text-left",
        "data": "telephone"
    },{
    	"sClass": "text-left",
        "data": "mobile"
    },{
    	"sClass": "text-left",
        "data": "familyTel"
    },{
    	"sClass": "text-left",
        "data": "workTel"
    },{
    	"sClass": "text-left",
        "data": "wechatNum"
    },{
    	"sClass": "text-left",
        "data": "serviceName"
    },{
    	"sClass": "text-left",
        "data": "makeOverDate"
    },{
    	"sClass": "text-left",
        "data": "expireNumber"
    }];
	
	var serviceExpireTable = function(){
		return matchTable('#serviceExpireTables','/home/getServiceExpirePageData.do',serviceExpireListArr,function(obj){
			
		},true);
	} 
	
	var planBuyExpireTable = function(){
		return matchTable('#planBuyExpireTables','/home/getPlanBuyExpirePageData.do',planBuyExpireListArr,function(obj){
			
		},true);
	}
	
	var planBuyReturnTable = function(){
		return matchTable('#planBuyReturnTables','/home/getPlanBuyReturnPageData.do',planBuyReturnListArr,function(obj){
			
		},true);
	}
	
	var mrExpireTable = function(){
		return matchTable('#mrExpireTables','/home/getMRExpirePageData.do',mrExpireListArr,function(obj){
			
		},true);
	}
	
	var memberRetrunTable = function(){
		return matchTable('#memberRetrunTables','/home/getMemberRetrunPageData.do',memberReturnListArr,function(obj){
			
		},true);
	} 
	
	var makeOverExpireTable = function(){
		return matchTable('#makeOverExpireTables','/home/getMakeOverExpirePageData.do',makeOverExpireListArr,function(obj){
			
		},true);
	} 

$(function(){
	
	serviceExpireTable();
	
	planBuyExpireTable();
    
	planBuyReturnTable();
	
	mrExpireTable();
	
	memberRetrunTable();
	
	makeOverExpireTable();
});


function rejectRenew(id){
	
	if (confirm("确定拒绝续约吗？")) {
    	$.ajax({
    		url : webroot + '/buyService/updateIfRenew.do',
    		data : {'id':id,'type': '0'},
    		type : 'post',
    		dataType : 'json',
    		success : function(result){
    			layer.msg(result.msg);
    			if(result.type=='2'){
    				serviceExpireTable().draw();
    			}
    		}
    	});
    }
}

function toReturnTimeForm(id){
	
	layer.open({
		  type : 2,
		  title: '下次回访时间', 
		  skin: 'demo-class',
		  offset : '5%',
		  content: webroot + "/home/toReturnTimeForm.do?memberId="+id,
		  area: ['40%','40%']
		});
}

